﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ElectronicJournal.Account.EditorAccount
{
    public partial class Patterns : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton_Click(object sender, EventArgs e)
        {
            DB.Item.ItemPattern item = new DB.DbPatterns().GetPatternInfo("00000000-0000-0000-0000-000000000000");
            HttpContext.Current.Response.ContentType = "APPLICATION/OCTET-STEAM";
            string Header = "Attachment; Filename=" + item.FileName;
            HttpContext.Current.Response.AppendHeader("Content-Disposition", Header);

            System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("/") + "\\Patterns\\" + item.FileName);
            HttpContext.Current.Response.WriteFile(file.FullName);
            HttpContext.Current.Response.End();
        }

        protected void Button_Click(object sender, EventArgs e)
        {
            string folder = Server.MapPath("/") + "\\Patterns\\";
            System.IO.Directory.CreateDirectory(folder);
            if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
            {
                FileUpload1.PostedFile.SaveAs(folder + System.IO.Path.GetFileName(FileUpload1.FileName));
            }
            new DB.DbPatterns().ChangePattern(FileUpload1.FileName);
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }  
    }
}